package com.fr.report.core.barcode;

import com.fr.report.cellElement.BarcodeAttr;
import com.fr.report.core.barcode.line.code128.Code128Barcode;
import com.fr.report.painter.BarcodePainter;
import java.io.Serializable;

public class BarCodeUtils
  implements Cloneable, Serializable
{
  public static BarcodeImpl getBarcodeImpl(BarcodePainter paramBarcodePainter)
    throws BarcodeException
  {
    return getBarcodeImpl(paramBarcodePainter.getBarcodeAttr(), paramBarcodePainter.getText());
  }

  public static BarcodeImpl getBarcodeImpl(BarcodeAttr paramBarcodeAttr, String paramString)
    throws BarcodeException
  {
    int i = paramBarcodeAttr.getType();
    if (paramString == null)
      paramString = "123456789";
    Object localObject = null;
    switch (i)
    {
    case 0:
      localObject = BarcodeFactory.createCode39(paramString, false);
      break;
    case 1:
      localObject = BarcodeFactory.createCode39(paramString, true);
      break;
    case 2:
      localObject = BarcodeFactory.createCodabar(paramString);
      break;
    case 3:
      localObject = new Code128Barcode(paramString, 3);
      break;
    case 4:
      localObject = new Code128Barcode(paramString, 0);
      break;
    case 5:
      localObject = new Code128Barcode(paramString, 1);
      break;
    case 6:
      localObject = new Code128Barcode(paramString, 2);
      break;
    case 7:
      localObject = BarcodeFactory.createEAN128(paramString);
      break;
    case 8:
      localObject = BarcodeFactory.createUSPS(paramString);
      break;
    case 9:
      localObject = BarcodeFactory.createShipmentIdentificationNumber(paramString);
      break;
    case 10:
      localObject = BarcodeFactory.createSSCC18(paramString);
      break;
    case 11:
      localObject = BarcodeFactory.createSCC14ShippingCode(paramString);
      break;
    case 12:
      localObject = BarcodeFactory.createGlobalTradeItemNumber(paramString);
      break;
    case 13:
      localObject = BarcodeFactory.createPDF417(paramString);
      break;
    case 14:
      localObject = BarcodeFactory.createUSD4(paramString);
      break;
    case 15:
      localObject = BarcodeFactory.createNW7(paramString);
    }
    if (localObject == null)
      localObject = BarcodeFactory.createCode39(paramString, false);
    ((BarcodeImpl)localObject).setBarWidth(paramBarcodeAttr.getBarWidth());
    ((BarcodeImpl)localObject).setBarHeight(paramBarcodeAttr.getBarHeight());
    ((BarcodeImpl)localObject).setDrawingText(paramBarcodeAttr.isDrawingText());
    return ((BarcodeImpl)localObject);
  }

  public static String getBarCodeTypeName(int paramInt)
  {
    switch (paramInt)
    {
    case 0:
      return "CODE39";
    case 1:
      return "CODE39CHECK";
    case 2:
      return "CODABAR";
    case 3:
      return "CODE128";
    case 4:
      return "CODE128A";
    case 5:
      return "CODE128B";
    case 6:
      return "CODE128C";
    case 7:
      return "EAN128";
    case 8:
      return "USPS";
    case 9:
      return "SHIPMENT_ID";
    case 10:
      return "SSCC-18";
    case 11:
      return "SCC-14";
    case 12:
      return "GTIN";
    case 13:
      return "PDF417";
    case 14:
      return "USD-4";
    case 15:
      return "NW-7";
    }
    return "CODE39";
  }

  public static Integer[] getAllSupportedBarCodeTypeArray()
  {
    int i = 16;
    Integer[] arrayOfInteger = new Integer[i];
    for (int j = 0; j < i; ++j)
      arrayOfInteger[j] = new Integer(j);
    return arrayOfInteger;
  }
}